//
//  LTChatManager.h
//  LTIM
//
//  Created by 俊松何 on 2017/4/14.
//  Copyright © 2017年 俊松何. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "LTChatManagerDelegate.h"
#import "LTMessage.h"
#import "LTConversation.h"
#import "LTError.h"
#import "LTChatManagerDelegate.h"

@interface LTChatManager : NSObject




@property (nonatomic,strong) NSMutableArray<id<LTChatManagerDelegate> >* chatMangerdelegateArray;


/**
 添加回调代理
 
 @param deleagte 要添加的代理
 */
-(void)addDelegate:(id<LTChatManagerDelegate>)deleagte;


/**
 移除回调

 @param delegate 移除的代理
 */
-(void)removeDelegate:(id<LTChatManagerDelegate>)delegate;

/**
 获取所有会话
 
 @return 会话列表<LTConversation>
 */
-(NSArray *)getAllConversations;

/**
 获取一个会话
 
 @param conversationId       会话ID
 @param ltuser               会话user
 @param type                 会话类型
 @param aifCreate            如果不存在创建
 @return  会话对象
 */
-(LTConversation *)getConversation:(NSString *)conversationId
                            ltuser:(LTUser *)ltuser
                              type:(LTChatType)type
                  createIfNotExist:(BOOL)aifCreate;


/**
 得到指定类型的小红点数量

 @param type  小红点消息类型
 @return 数量
 */
-(NSInteger)getRedDotNumberWithType:(LTNoticeMessageType)type;



-(BOOL)addRedDotWithType:(LTNoticeMessageType)type;

/**
 删除置顶类型的小红点

 @param type 小红点消息类型
 @return 操作成功没有
 */
-(BOOL)deleteRedDotWithType:(LTNoticeMessageType)type;

/**
 删除会话
 
 @param ConversationId    会话ID
 @param IsDeleteMessages  是否删除会话中的消息
 @param CompletionBlock   完成的回调
 */
- (void)deleteConversation:(NSString *)ConversationId
          isDeleteMessages:(BOOL)IsDeleteMessages
                completion:(void (^)(NSString *aConversationId, LTError *lterror))CompletionBlock;




/**
 插入一条消息到db

 @param Message 插入的消息
 @return 插入的结果
 */
- (BOOL)insertMessage:(LTMessage *)Message;

/**
 从db删除一条消息
 
 @param Message 删除的消息
 @return 插入的结果
 */
- (BOOL)deleteMessage:(LTMessage *)Message;


/**
 更新消息到DB
 
 @param Message 消息
 @param CompletionBlock 完成的回调
 */
- (void)updateMessage:(LTMessage *)Message
           completion:(void (^)(LTMessage *aMessage, LTError *aError))CompletionBlock;



/**
 下载缩略图（图片消息的缩略图或视频消息的第一帧图片），SDK会自动下载缩略图，所以除非自动下载失败，用户不需要自己下载缩略图
 
 @param Message              消息
 @param ProgressBlock        附件下载进度回调block
 @param CompletionBlock      下载完成回调block
 */
- (void)downloadMessageThumbnail:(LTMessage *)Message
                        progress:(void (^)(int progress))ProgressBlock
                      completion:(void (^)(LTMessage *message, LTError *error))CompletionBlock;


/**
 SDK会自动下载语音消息，所以除非自动下载语音失败，用户不需要自动下载语音附件
 
 @param Message              消息
 @param ProgressBlock        附件下载进度回调block
 @param CompletionBlock      下载完成回调block
 */
- (void)downloadVoiceMessageAttachment:(LTMessage *)Message
                              progress:(void (^)(int progress))ProgressBlock
                            completion:(void (^)(LTMessage *message, LTError *error))CompletionBlock;



/**
 下载原始图片或者封面图，isthumbnail 判断下载是否是封面
 
 @param Message 消息
 @param ProgressBlock    图片下载进度回调block
 @param CompletionBlock  下载完成回调block
 */
- (void)downloadImageMessageAttachment:(LTMessage *)Message
                              progress:(void (^)(int progress))ProgressBlock
                           isthumbnail:(BOOL)isthumbnail
                            completion:(void (^)(LTMessage *message, LTError *error))CompletionBlock;



/**
 下载视频

 @param Message 消息
 @param ProgressBlock   视频下载进度
 @param CompletionBlock 下载完成回调block
 */
- (void)downloadVideoMessageAttachment:(LTMessage *)Message
                              progress:(void (^)(int progress))ProgressBlock
                            completion:(void (^)(LTMessage *message, LTError *error))CompletionBlock;


/**
 下载视频封面图
 
 @param Message 消息
 @param ProgressBlock   视频下载进度
 @param CompletionBlock 下载完成回调block
 */
- (void)downloadVideoCoverMessageAttachment:(LTMessage *)Message
                                  progress:(void (^)(int progress))ProgressBlock
                                completion:(void (^)(LTMessage *message, LTError *error))CompletionBlock;


/**
 下载文件
 
 @param Message 消息
 @param ProgressBlock   文件下载进度
 @param CompletionBlock 下载完成回调block
 */
- (void)downloadFileMessageAttachment:(LTMessage *)Message
                              progress:(void (^)(int progress))ProgressBlock
                            completion:(void (^)(LTMessage *message, LTError *error))CompletionBlock;


/**
 发送消息
 
 @param message             消息
 @param progressBlock       附件上传进度block
 @param completionBlock     发送完成回调block
 */
-(void)sendMessage:(LTMessage *)message
          progress:(void(^)(int progress))progressBlock
        completion:(void(^)(LTMessage *message,LTError *error))completionBlock;


/**
 翻译语音消息

 @param message    文本消息
 @param completionBlock 翻译完成的回调
 */
-(void)translateMessage:(LTMessage *)message
             tolanguage:(NSString *)tolanguage
             completion:(void(^)(LTMessage *message,LTError *error))completionBlock;


-(void)translateWithContent:(NSString *)content
                 tolanguage:(NSString *)tolanguage
                 completion:(void(^)(NSString *result,LTError *error))completionBlock;



/**
 消息转发  (防止重复上传资源文件)
 
 @param message 消息
 @param completionBlock 发送完成回调block
 */
-(void)transfromMessage:(LTMessage *)message
             completion:(void(^)(LTMessage *message,LTError *error))completionBlock;



@end
